<!-- components/WaveText.vue -->
<template>
  <span class="wave-text" :style="waveStyle">
    {{ text }}
  </span>
</template>

<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
  text: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: '#fff'
  },
  waveColor: {
    type: String,
    default: 'rgba(255,255,255,0.5)'
  },
  duration: {
    type: Number,
    default: 3
  }
})

const waveStyle = computed(() => ({
  '--wave-color': props.waveColor,
  '--text-color': props.color,
  '--duration': `${props.duration}s`
}))
</script>

<style lang="scss" scoped>
.wave-text {
  cursor: default;
  position: relative;
  display: inline-block;
  color: var(--text-color);
  background-clip: text;
  -webkit-background-clip: text;
  background-image: linear-gradient(90deg,
      var(--wave-color) 0%,
      transparent 50%,
      var(--wave-color) 100%);
  background-size: 200% auto;
  -webkit-text-fill-color: transparent;
  animation: wave var(--duration) linear infinite;

  @keyframes wave {
    0% {
      background-position: 0% center;
    }

    100% {
      background-position: -200% center;
    }
  }
}
</style>
